package com.douqu.game.core.platform;

import com.bean.core.util.HttpStringUtil;
import com.douqu.game.core.factory.PlatformFactory;
import com.douqu.game.core.i.IPlatform;
import com.douqu.game.core.protobuf.SGCommonProto;
import com.douqu.game.core.util.CoreUtils;
import com.douqu.game.core.util.LogUtils;

import java.text.MessageFormat;

public class PlatformQuickSDK implements IPlatform
{
    @Override
    public String auth(String account, String password)
    {
        String url = MessageFormat.format(PlatformFactory.QUICKSDK_CHECK_LOGIN_URL, password, PlatformFactory.QUICKSDK_PRODUCT_CODE, account);
        LogUtils.info("QUICKSDK url -> " + url);
        String result = HttpStringUtil.sendHttpPost(url);
        LogUtils.info("QUICKSDK auth result -> " + result);
        if(!result.equals("1"))
        {
            LogUtils.error("QUICKSDK验证用户信息失败:account->" + account + "  password->" + password);
            return null;
        }

        return CoreUtils.createAccount(account, SGCommonProto.E_CHANNEL_TYPE.CHANNEL_TYPE_QUICKSDK);
    }

}
